package clue.util;

public class Utilities {
	private static final int[] MultiplyDeBruijnBitPosition2 = { 0, 1, 28, 2,
			29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21,
			19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 };
	
	public static int getBitPosition(long v) {
		return MultiplyDeBruijnBitPosition2[((int)v * 0x077CB531) >>> 27];
	}
	
	//
	// V only uses 21 LSB, and is dense
	//
	public static int bitcount_21dense(long v) {
		int c;
		for (c = 21, v = ~v & 0x1FFFFF; v != 0; c--, v &= v-1);
		return c;
	}
	
	public static void printLongBinary(long l) {
		System.out.println(Long.toBinaryString(l));
	}
	
	public static void main(String[] args) {
		Utilities.printLongBinary(-9223372036853150916l);
	}
}
